package base.utils;

import javax.servlet.http.HttpServletRequest;

public class PathAsURL {

	private String projectName; //工程名称
	private String controlURI; //controller路径名称
	private String shortURI; //DAO名称
	private boolean pass; //验证是否通过过滤条件
	private String url; //相对路径

	public String getProjectName() {
		return projectName;
	}
	public String getControlURI() {
		return controlURI;
	}
	public String getShortURI() {
		return shortURI;
	}
	public boolean isPass() {
		return pass;
	}

	public String getURI(){
		return this.url;
	}

	public PathAsURL(HttpServletRequest request){
		super();

		//分析请求地址
		this.url = request.getServletPath();
		String[] dow = url.split("/");
		this.projectName = request.getContextPath();
		this.controlURI = "/" + dow[1];
		this.shortURI = "/" + dow[2];

		//无需过滤条件
		if(shortURI.equals("/login.do")
			|| shortURI.equals("/signOut.do")
			|| shortURI.equals("/register.do")
			|| shortURI.equals("/toRegister.do")
			|| shortURI.equals("/emailCheck.do")
			|| shortURI.equals("/resendchkmail.do")
			|| shortURI.equals("/commInformation.do")
			|| shortURI.equals("/shopComm.do")
			|| shortURI.equals("/showCommToSup.do")
			|| shortURI.equals("/protocol.do")
			|| shortURI.equals("/showCommOnIndex.do")
			|| shortURI.equals("/toLogin.do")
			|| url.equals("/search/getList.do")
			|| url.equals("/search/theme.do")
			|| url.equals("/user/advert.do")
			|| shortURI.equals("/passFind.do")
			|| shortURI.equals("/toPassFind.do")
			|| shortURI.equals("/mail.do")
			|| shortURI.equals("/payCompleteFront.do")
			|| shortURI.equals("/payCompleteBack.do")
			||shortURI.equals("/bycatToComm.do")
			||shortURI.equals("/getCommCat.do")
			||shortURI.equals("/singleCommentList.do")
			||shortURI.equals("/toem.do")
			||shortURI.equals("/toemUser.do")
			||shortURI.equals("/toemSup.do")
			||shortURI.equals("/menu.do")
			||shortURI.equals("/selectArtList.do")
			||shortURI.equals("/articleClassList.do")
			|| url.equals("/user/categoryList.do")
			|| url.equals("/menu/commodityAssortList.do")
			|| url.equals("/trade/toTrade.do")
			|| url.equals("/trade/tradeAdd.do")
			|| url.equals("/trade/toAdvert.do")
			|| url.equals("/trade/advertAdd.do")
			|| url.equals("/trade/tradecomm.do")
			|| url.equals("/user/getIP.do")
			|| url.equals("/trade/tradecommclass.do")
			|| url.equals("/trade/commString.do")
			|| url.equals("/user/changeCity.do")
			|| url.equals("/add/selectAddr.do")
			|| url.equals("/special/frontlist.do")
			|| url.equals("/special/frontajax.do")
			|| url.equals("/user/getIP.do")
			|| url.equals("/user/city.do")
			|| url.equals("/trade/addAdvert.do")
			
			){
				this.pass = true;
		}
		//验证邮箱验证页面
		if(shortURI.equals("/registcpy_b.do")){
			this.pass = true;
		}

		//验证码
		if (controlURI.equals("/kaptcha") && shortURI.equals("/kcaptchaImage.do")) {
			this.pass = true;
		}
	}

}